package com.aclass.xqx.classscreen.db;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.ToOne;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.annotation.Unique;

/**
 * Created by xqx on 2017/11/16.
 * 卡号
 */
@Entity
public class Cardnumber {
    @Id
    private String id;//卡号id
    @Unique
    private String  cardnumber;//卡号
    private int type;//卡号类型
    @ToOne(joinProperty = "id")
    private CardStudent cardStudnet;//关联学生
    @ToOne(joinProperty = "id")
    private CardTeacher cardTeacher;//关联老师
    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;
    /** Used for active entity operations. */
    @Generated(hash = 61826828)
    private transient CardnumberDao myDao;
    @Generated(hash = 368288435)
    public Cardnumber(String id, String cardnumber, int type) {
        this.id = id;
        this.cardnumber = cardnumber;
        this.type = type;
    }
    @Generated(hash = 814580316)
    public Cardnumber() {
    }
    public String getId() {
        return this.id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getCardnumber() {
        return this.cardnumber;
    }
    public void setCardnumber(String cardnumber) {
        this.cardnumber = cardnumber;
    }
    public int getType() {
        return this.type;
    }
    public void setType(int type) {
        this.type = type;
    }
    @Generated(hash = 37746044)
    private transient String cardStudnet__resolvedKey;
    /** To-one relationship, resolved on first access. */
    @Generated(hash = 438318351)
    public CardStudent getCardStudnet() {
        String __key = this.id;
        if (cardStudnet__resolvedKey == null || cardStudnet__resolvedKey != __key) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            CardStudentDao targetDao = daoSession.getCardStudentDao();
            CardStudent cardStudnetNew = targetDao.load(__key);
            synchronized (this) {
                cardStudnet = cardStudnetNew;
                cardStudnet__resolvedKey = __key;
            }
        }
        return cardStudnet;
    }
    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 224339259)
    public void setCardStudnet(CardStudent cardStudnet) {
        synchronized (this) {
            this.cardStudnet = cardStudnet;
            id = cardStudnet == null ? null : cardStudnet.getId();
            cardStudnet__resolvedKey = id;
        }
    }
    @Generated(hash = 1492591292)
    private transient String cardTeacher__resolvedKey;
    /** To-one relationship, resolved on first access. */
    @Generated(hash = 988074544)
    public CardTeacher getCardTeacher() {
        String __key = this.id;
        if (cardTeacher__resolvedKey == null || cardTeacher__resolvedKey != __key) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            CardTeacherDao targetDao = daoSession.getCardTeacherDao();
            CardTeacher cardTeacherNew = targetDao.load(__key);
            synchronized (this) {
                cardTeacher = cardTeacherNew;
                cardTeacher__resolvedKey = __key;
            }
        }
        return cardTeacher;
    }
    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 2091414001)
    public void setCardTeacher(CardTeacher cardTeacher) {
        synchronized (this) {
            this.cardTeacher = cardTeacher;
            id = cardTeacher == null ? null : cardTeacher.getId();
            cardTeacher__resolvedKey = id;
        }
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }
    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 1043017292)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getCardnumberDao() : null;
    }

}
